import request from "@/utils/request";

import type { addSkuData, findSkuInfo, lookAllSku } from "@/api/acl/SKU/type";

enum API {
    // 增加 SKU
    ADD_SKU = "/admin/product/saveSkuInfo",
    // 查看对应SPU的SKU
    FIND_SKU = "/admin/product/findBySpuId/",
    // 查看所有的SKU
    LOOK_ALL_SKU = "/admin/product/list/",
    // 上架SKU
    ONSALE_SKU = "/admin/product/onSale/",
    // 下架SKU
    CANCAL_SKU = "/admin/product/cancelSale/",
    // 获得特定的sku
    GET_A_SKU = "/admin/product/getSkuInfo/",
    // 删除SKU
    DELETE_SKU = "/admin/product/deleteSku/",
}

export const add_sku = (data: addSkuData) => request.post(API.ADD_SKU, data);

export const find_sku = (spuId: number) => request.get<any, findSkuInfo>(API.FIND_SKU + spuId);

export const look_all_sku = (page: number, limit: number) =>
    request.get<any, lookAllSku>(API.LOOK_ALL_SKU + `${page}/${limit}`);

export const onSale_sku = (spuId: number) => request.get<any, any>(API.ONSALE_SKU + spuId);

export const cancelSale = (spuId: number) =>
    request.get<any, any>(API.CANCAL_SKU + spuId);

export const getOneSku = (spuId: number) => request.get<any, any>(API.GET_A_SKU + spuId);

export const deleteOneSku = (spuId: number) => request.delete<any, any>(API.DELETE_SKU+spuId);

